<template>
  <div :class="{'app-container':!isCommon}">
    <p>近一个月商品销售排行（销售金额累计TOP50）</p>
    <div class="chart-wrapper-box">
      <el-table
        :header-cell-style="{'text-align':'center'}"
        :cell-style="{'text-align':'center'}"
        :data="spxsData"
        border
        style="width: 100%"
        v-loading="spxsloading"
      >
        <el-table-column prop="index" label="序号" width="50">
        </el-table-column>
        <el-table-column prop="productName" label="商品名称"></el-table-column>
        <el-table-column prop="orderNumber" label="订单数"/>
        <el-table-column prop="saleNumber" label="销售金额"/>
        <el-table-column prop="profitAmount" label="利润"/>
        <el-table-column prop="profitRate" label="利润率"/>
      </el-table>
      <pagination
        v-show="spxstotal>0"
        :total="spxstotal"
        :page.sync="spxsParams.pageNum"
        :limit.sync="spxsParams.pageSize"
        @pagination="getHeadOfficeGoodSaleRankingMonthData"
      />
    </div>
  </div>
</template>

<script>
import {HeadOfficeGoodSaleRankingMonthData} from "@/api/index";

export default {
  name: "productData",
  props: {
    isCommon: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      spxsData: [],
      spxsloading: false,
      spxstotal: 0,
      spxsParams: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  created() {
    this.getHeadOfficeGoodSaleRankingMonthData()
  },
  methods: {
    // 近一个月商品销售排行（销售金额累计TOP50）
    getHeadOfficeGoodSaleRankingMonthData() {
      this.spxsloading = true;
      HeadOfficeGoodSaleRankingMonthData(this.spxsParams).then(res => {
        this.spxsData = res.records;
        this.spxstotal = res.total;
        this.spxsloading = false;
      })
    },
  }
}
</script>

<style scoped>

</style>
